package com.xbmd.assistant.controller;

import com.xbmd.assistant.aiservice.ConsultantService;
import dev.langchain4j.model.openai.OpenAiChatModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RestController
public class ChatController {

//    @Autowired
//    private OpenAiChatModel model;
//    //浏览器传递的用户问题
//
//    @RequestMapping("/chat")
//    public String chat(String message) {
//        String result = model.chat(message);
//        return result;
//    }

    @Autowired
    private ConsultantService consultantService;

//    @RequestMapping("/chat")
//    public String chat(String message) {
//        String result = consultantService.chat(message);
//        return result;
//    }


    @RequestMapping(value = "/chat" ,produces = "text/html;charset=utf-8")
    public Flux<String> chat(String memoryId,String message) {
        Flux<String> result = consultantService.chat(memoryId,message);
        return result;
    }
}
